#+_+ coding:utf-8 +_+

import redis_proxy

def Add(uid,newsID,author,comment,timestmp):
    commentID = GenerateCommentID()
    redis_proxy.AddComment(uid,newsID,commentID,author,comment,timestmp)
    return commentID


def GenerateCommentID():
    rst = redis_proxy.GenerateCommentID()
    return rst

def Get(newsID):
    """ return comments list of news newsID """
    rst  = redis_proxy.GetComments(newsID)
    comments = list()
    for i in rst:
        c = redis_proxy.GetComment(i)
        item =  dict(author=c["author"],content=c["content"],time=c["timestmp"])
        comments.append(item)
    return comments


def CheckCommentID(id):
    rst = redis_proxy.CheckCommentID(id)
    return rst

        
